module.exports = (sequelize, DataTypes) => {
    const Propose = sequelize.define('Propose', {
        id: {
            type: DataTypes.BIGINT.UNSIGNED,
            allowNull: false,
            autoIncrement: true,
            primaryKey: true
        },
        detail: {
            type: DataTypes.STRING,
            allowNull: false,
            validate: {
                notNull: {
                    msg: '意见不能为空'
                }
            }
        },
        user_id: {
            type: DataTypes.BIGINT.UNSIGNED,
            allowNull: false,
            validate: {
                notNull: {
                    msg: '反馈人员不能为空'
                }
            },
            references: {
                model: 'User',
                key: 'id'
            }
        }
    })

    Propose.associate = function(models) {
        models.Propose.belongsTo(models.User, { foreignKey: 'user_id', targetKey: 'id' })
    }

    return Propose
}
